use std::fmt;

use serde::{Deserialize, Serialize};

{{ doc_comment }}
#[derive(
    Clone, Copy, Debug, Default, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize,
)]
pub enum {{ type.name | to_upper_camel_case }} {
    {% for value in type.values -%}
        {% if loop.first -%}
            #[default]
        {% endif -%}
        #[serde(rename = "{{ value }}")]
        {{ value | to_upper_camel_case }},
    {% endfor -%}
}

impl fmt::Display for {{ type.name | to_upper_camel_case }} {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        let value = match self {
            {% for value in type.values -%}
                Self::{{ value | to_upper_camel_case }} => "{{ value }}",
            {% endfor -%}
        };
        f.write_str(value)
    }
}
